import Vue from 'vue'
import Router from 'vue-router'

Vue.use(Router)

/* Layout */
import Layout from '@/layout'

/**
 常量路由
 所有的用户都可以看到的路由界面 【首页和登录界面】
 */
export const constantRoutes = [
  {
    path: '/login',
    component: () => import('@/views/login/index'),
    hidden: true
  },

  {
    path: '/404',
    component: () => import('@/views/404'),
    hidden: true
  },

  {
    path: '/',
    component: Layout,
    redirect: '/welcome',
    meta: {title: '首页', icon: 'dashboard'},
    children: [{
      path: 'welcome',
      name: 'WelCome',
      component: () => import('@/views/dashboard/WelCome/index'),
      meta: {title: '通知'}
    },
      {
        path:'dataShow',
        name:'DataShow',
        component:()=> import('@/views/dashboard/DataShow'),
        meta: {title:'数据报表'}
      }]
  },

]

/**
 异步路由
 需要权限才可以访问的路由
 */
export const asyncRoutes = [
  // 商品路由
  {
    path: '/product',
    name: 'Product',
    component: Layout,
    meta: {title: '商品管理', icon: 'el-icon-goods'},
    children: [{
      path: 'attr',
      name: 'Attr',
      component: ()=>import("@/views/product/Attr"),
      meta: {title: '平台售卖属性管理'}
    },
      {
        path: 'trademark',
        name: 'TradeMark',
        component: ()=>import("@/views/product/TradeMark"),
        meta: {title: '品牌管理'}
      },
      {
        path: 'sku',
        name: 'Sku',
        component: ()=>import("@/views/product/Sku"),
        meta: {title: 'Sku'}
      },
      {
        path: 'spu',
        name: 'Spu',
        component: ()=>import("@/views/product/Spu"),
        meta: {title: 'Spu'}
      }]
  },
  // 权限路由
  {
    path: '/power',
    name: 'Acl',
    component: Layout,
    meta: {title: '权限管理', icon: 'el-icon-lock'},
    children: [{
      path: 'user',
      name: 'User',
      component: ()=>import("@/views/power/User"),
      meta: {title: '用户管理'}
    },
      {
        path: 'role',
        name: 'Role',
        component: ()=>import("@/views/power/Role"),
        meta: {title: '角色管理'}
      },
      {
        path: 'menu',
        name: 'Permission',
        component: ()=>import("@/views/power/Menu"),
        meta: {title: '菜单管理'}
      }]
  }
]

/**
 任意路由
 当路径出现错误时跳转到这个路由
 */
export const anyRoutes = [{path: '*', redirect: '/404', hidden: true}]

// 创建路由的实例
const router = new Router({
  scrollBehavior: () => ({y: 0}),
  routes: constantRoutes
})

export default router
